//a.判断背景颜色
if ($(".read_time").attr("check") == "true") {
    for (var i = 0; i < $("footer>div>ul>li").length; i++) {
        if ($("footer>div>ul>li").eq(i).attr("class") == "active") {
            console.log(i)
            $(".read_time").attr("check", "true");
            daytime();
            $(".text_Info").css("background", $("footer>div>ul>li").eq(i).attr("date-color"));
            $("#wrapper").css("background", $("footer>div>ul>li").eq(i).attr("date-color"));
        }
    }
} else {
    daytime();
}
//b.判断阅读方式
if ($("footer>div>p").eq(0).attr("class") == "active") {
    document.getElementsByClassName("box_box")[0].removeEventListener("touchmove", function (e) {
        var e = e || event;
        e.preventDefault()
    });
    $("#wrapper").css("display", "block").css("transform", "translateY(0)");
    $(".text_Info").css("display", "none");
} else {
    //阻止页面上下滚
    document.getElementsByClassName("box_box")[0].addEventListener("touchmove", function (e) {
        var e = e || event;
        e.preventDefault()
    });
    $("#wrapper").css("display", "none");
    $(".text_Info_cont").css("transform", "translateX(0)");
    numpage = 0;
    $(".text_Info").css("display", "block")
}
//选择章节布局样式
$(".sectionCont").height(parseInt($(window).height()) - (2.13 + 2.99) / 2 * 46.875 + "px")
//关闭选择章节界面
$(".sectionHead img").on("click", function () {
    $(".chooseSection").css("display", "none")
})
//显示选择章节界面
$("header span").eq(1).on("click", function (e) {
//    $(".getmoreSection").trigger("click")
    var e = e || event;
    e.stopPropagation();
    $(".chooseSection").css("display", "block");
})
$(".getmoreSection").on("click", function (e) {
    var e = e || event;
    e.stopPropagation();
    $(".chooseSection").css("display", "block");
})
// 订阅相应的章节

//关闭同步阅读进度界面
$(".told_press li").eq(0).on("click", function () {
    $(".told_press").css("display", "none")
})
//如果余额为零显示充值订阅
if ($(".sectionFoot>p>a>i").html() == "0") {
    $(".sectionFoot>span").html("充值订阅")
}
//取消自动订阅功能
$(".loginMoney>span>img").on("click", function (e) {
    var e = e || event;
    e.stopPropagation();
    if ($(this).attr("check") == "true") {
        $(this).attr("src", "/public/img/images/btn-nocheck.png");
        $(this).attr("check", "false")
    } else {
        $(this).attr("check", "true");
        $(this).attr("src", "/public/img/images/btn-check.png")
    }
})

var goSection = 0;
var goPrice = 0;
$(".sectionCont>li").on("click", function () {
    if ($(this).attr("check") == "false") {
        $(this).attr("check", "true");
        $(this).find("img").attr("src", "/public/img/images/btn-check.png")
        goSection++;
        goPrice += parseInt($(this).attr("price"));
        $(".sectionFoot>p>span>i").eq(1).html(goPrice);
        $(".sectionFoot>p>span>i").eq(0).html(goSection)
    } else {
        $(this).attr("check", "false");
        $(this).find("img").attr("src", "/public/img/images/btn-nocheck.png")
        goSection--;
        goPrice = goPrice - parseInt($(this).attr("price"));
        $(".sectionFoot>p>span>i").eq(0).html(goSection);
        $(".sectionFoot>p>span>i").eq(1).html(goPrice);
    }
})
//全选效果
$(".sectionHead>span").on("click", function () {
    $(".sectionCont>li").attr("check", "true");
    $(".sectionCont>li").find("img").attr("src", "/public/img/images/btn-check.png")
    $(".sectionFoot>p>span>i").eq(0).html($(".sectionCont>li").length)
    goSection = $(".sectionCont>li").length;
    var allPrice = 0;
    for (var i = 0; i < $(".sectionCont>li").length; i++) {
        allPrice += parseInt($(".sectionCont>li").eq(i).attr("price"))
    }
    goPrice = allPrice
    $(".sectionFoot>p>span>i").eq(1).html(allPrice);
})
//充值订阅
$(".sectionFoot>span").on("click", function () {
    location.href = "../user/payfor"
})
//查看图书详情
$("header>span").eq(0).on("click", function () {
    location.href = "../novel/novelInfo?novelid=" + novelid
})

//点击文章中心显示设置
$(".text_Info").bind("click", function () {
    if (parseInt($("header").css("top")) < 0) {
        $("header").css("top", "0rem");
        $("footer").css("bottom", "0rem");
        $("aside").css("right", "0rem")
    } else {
        $(".propress").attr("check", "false");
        $(".set_show").attr("check", "false");
        show();
        $("header").css("top", "-2.13rem");
        $("footer").css("bottom", "-7.68rem");
        $("aside").css("right", "-4.72rem");
        //下方设置恢复默认
    }

})

//加入书架
$("aside").on('click', function () {
    $.ajax({
        url: "/novel/novel/addBookCase",
        type: "post",
        dataType: "json",
        data: {novelid: novelid},
        success: function (data) {
            if (data.status == 0) {
                $(".message_info_alert>span").html("添加成功");
                $(".message_info_alert").fadeIn(function () {
                    setTimeout(function () {
                        $(".message_info_alert").fadeOut()
                    }, 300)
                })
            } else {
                $(".message_info_alert>span").html(data.msg);
                $(".message_info_alert").fadeIn(function () {
                    setTimeout(function () {
                        $(".message_info_alert").fadeOut()
                    }, 300)
                })
            }
        }
    });
});

$(".scroller").on("click", function () {
    $(".text_Info").trigger("click")
})

//显示目录
$(".booklist").on("click", function () {
    $(".aside_booklist").css("visibility", "visible").css("transition", "none").css("background", "rgba(0,0,0,0.4)")
    $(".aside_booklist>div").css("transform", "translateX(0)");
    $(".aside_booklist>ul").css("transform", "translateX(0)");
    $("html").css("overflow", "none")
    $(".aside_booklist").on("click", function () {
        $(".aside_booklist").css("visibility", "hidden");
        $(".aside_booklist>div").css("transform", "translateX(14.02rem)");
        $(".aside_booklist>ul").css("transform", "translateX(14.02rem)");
        $("html").css("overflow", "auto")
    })
//	$(".aside_booklist>ul>li").bind("click",function(e){
//		var e=e||event;
//		e.cancelBubble=true;
//		//点击跳转相应的章节
//		console.log($(this).index())
//	})
})
show()
function show() {
    if ($(".set_show").attr("check") == "false") {
        $(".set").css("display", "none");
        $(".set_show>img").attr("src", "/public/img/images/menu-设置.png");
    } else {
        $(".set_show>img").attr("src", "/public/img/images/menu-设置-input.png");
    }
    ;
    if ($(".propress").attr("check") == "false") {
        $(".schedule").css("display", "none");
        $(".propress>img").attr("src", "/public/img/images/menu-进度.png");
    } else {
        $(".propress>img").attr("src", "/public/img/images/menu-进度-input.png");

    }
}


//设置界面的显示隐藏
$(".set_show").on("click", function () {
    if ($(this).attr("check") == "false") {
        $(this).attr("check", "true");
        $(".set").css("display", "block");
        $(".propress").attr("check", "false");
        show()
    } else {
        $(this).attr("check", "false");
        $(".set").css("display", "none");
        show()
    }
})
//进度界面的显示隐藏
$(".propress").bind("click", function () {
    if ($(this).attr("check") == "false") {
        $(this).attr("check", "true");
        $(".schedule").css("display", "block");
        $(".set_show").attr("check", "false");
        show()
    } else {
        $(this).attr("check", "false");
        $(".schedule").css("display", "none");
        show()
    }
})
//阅读背景颜色的切换
$("footer>div>ul>li").on("click", function () {
    $(".read_time").attr("check", "true");
    daytime();
    $("footer>div>ul>li").removeClass("active");
    $(this).addClass("active");
    $(".text_Info").css("background", $(this).attr("date-color"))
    $("#wrapper").css("background", $(this).attr("date-color"))
})

//日间、夜间的切换
$(".read_time").on("click", function () {
    daytime();
})
//daytime();
function daytime() {
    if ($(".read_time").attr("check") == "false") {
        $("footer>div>ul>li").removeClass("active");
        $(".read_time").attr("check", "true");
        $(".read_time").find("img").attr("src", "/public/img/images/menu-白天.png");
        $(".read_time").find("p").html("日间");
        $("body").css("background", "transparent")
        $(".text_Info").css("background", "#343434");
        $(".text_Info p").css("color", "#8A8B8F");
        $("section h3").css("color", "#8A8B8F");
        $("#wrapper").css("background", "#343434");
        $("#wrapper").find("p").css("color", "#8A8B8F");
        $(".loginMoney>a").eq(0).css("color", "#8A8B8F");
        $(".loginMoney>span>a").css("color", "#8A8B8F");
    } else {
        $(".read_time").attr("check", "false");
        $(".read_time").find("img").attr("src", "/public/img/images/menu-night.png");
        $(".read_time").find("p").html("夜间");
        $(".text_Info").css("background", "transparent");
        $(".text_Info p").css("color", "#322F24");
        $("section h3").css("color", "#322F24");
        $("#wrapper").css("background", "transparent");
//        $("body").css("background", "url('/public/img/images/moneyBack.png')  no-repeat").css("backgroundAttachment", "fixed").css("backgroundPosition", "bottom")
        $("#wrapper").find("p").css("color", "#322F24");
        $(".loginMoney>a").eq(0).css("color", "#666");
        $(".loginMoney>span>a").css("color", "#666");
    }
}

//重新连接网络
$(".loading").on("click", function () {
    location.reload()
})


//close提示页面（我知道了）
$(".IKnow").on("click", function () {
    $(".message_once").css("display", "none")
})


//滑块控制字体大小
$(".font_set>input").on("input propertychange", function () {
//    $(".font_set>input").val($(this).val() + 4);
    $(".text_Info p").css("fontSize", $(this).val() / 46.875 + "rem");
    $("#wrapper p").css("fontSize", $(this).val() / 46.875 + "rem");
    $(".text_Info h3").css("fontSize", $(this).val() / 46.875 * 92 / 77 + "rem");
    $("#wrapper h3").css("fontSize", $(this).val() / 46.875 * 92 / 77 + "rem");
})
$(".max").on("click", function () {
    if (parseInt($(".font_set>input").val()) < $(".font_set>input").attr("max")) {
        $(".font_set>input").val(parseInt($(".font_set>input").val()) + 4);
        $(".text_Info p").css("fontSize", (parseInt($(".font_set>input").val()) + 4) / 46.875 + "rem");
        $("#wrapper p").css("fontSize", (parseInt($(".font_set>input").val()) + 4) / 46.875 + "rem");
        $(".text_Info h3").css("fontSize", (parseInt($(".font_set>input").val()) + 4) / 46.875 * 92 / 77 + "rem");
        $("#wrapper h3").css("fontSize", (parseInt($(".font_set>input").val()) + 4) / 46.875 * 92 / 77 + "rem");

    } else {
        $(".font_set>input").val($(".font_set>input").attr("max"))
    }
})
$(".min").on("click", function () {
    if (parseInt($(".font_set>input").val()) > $(".font_set>input").attr("min")) {
        $(".font_set>input").val(parseInt($(".font_set>input").val()) - 4);
        $(".text_Info p").css("fontSize", (parseInt($(".font_set>input").val()) - 4) / 46.875 + "rem");
        $("#wrapper p").css("fontSize", (parseInt($(".font_set>input").val()) - 4) / 46.875 + "rem");
        $(".text_Info h3").css("fontSize", (parseInt($(".font_set>input").val()) + 4) / 46.875 * 92 / 77 + "rem");
        $("#wrapper h3").css("fontSize", (parseInt($(".font_set>input").val()) + 4) / 46.875 * 92 / 77 + "rem");
    } else {
        $(".font_set>input").val($(".font_set>input").attr("min"))
    }
})
//阅读方式的切换
$("footer>div>p").on("click", function () {
    $("footer>div>p").removeClass("active");
    $(this).addClass("active");
})
var move = function (e) {
    var e = e || event;
    e.preventDefault();
    // e.stopPropagation();
}
$(".set>p").eq(0).on("click", function () {
    // 允许页面上下滚
    // document.addEventListener("touchmove",move,false)
//    document.removeEventListener("touchmove", move, false)
    document.getElementsByClassName("box_box")[0].addEventListener("touchmove", function (e) {
        var e = e || event;
        e.preventDefault()
    });
    $("#wrapper").css("display", "block").css("transform", "translateY(0)");
    $(".text_Info").css("display", "none");
})
$(".set>p").eq(1).on("click", function () {
    //阻止页面上下滚
    document.addEventListener("touchmove", move, false)
    $("#wrapper").css("display", "none");
    $(".text_Info_cont").css("transform", "translateX(0)");
    numpage = 0;
    $(".text_Info").css("display", "block")

})
//小说正文左右页切换
var numpage = 1;
$(".next_page").on("click", function (e) {
    var e = e || event;
    e.stopPropagation();
    if (parseInt(numpage) * parseInt(document.body.clientWidth) >= a.scrollWidth) {
        
        pullUpAction('down', 'left');
        
    } else {
        $(".text_Info_cont").css("transform", "translateX(-" + numpage * 100 + "%)");
        numpage++;
    }
});
$(".prev_page").on("click", function (e) {
    var e = e || event;
    e.stopPropagation();
    if (numpage <= 1) {
        console.log("到头了")
        $(".text_Info_cont").css("transition", "none");
        // 调用数据
        pullUpAction('up', 'left');
        setTimeout(function () {
            $(".text_Info_cont").css("transition", "transform .2s");
        }, 400)
    } else {
        numpage--;
        $(".text_Info_cont").css("transform", "translateX(-" + (numpage - 1) * 100 + "%)")
    }
})

//左右滑动切换页面
var startx, starty;
//获得角度
function getAngle(angx, angy) {
    return Math.atan2(angy, angx) * 180 / Math.PI;
}
;

//根据起点终点返回方向 1向上 2向下 3向左 4向右 0未滑动
function getDirection(startx, starty, endx, endy) {
    var angx = endx - startx;
    var angy = endy - starty;
    var result = 0;

    //如果滑动距离太短
    if (Math.abs(angx) < 30 && Math.abs(angy) < 30) {
        return result;
    }
    var angle = getAngle(angx, angy);
    if (angle >= -135 && angle <= -45) {
        result = 1;
    } else if (angle > 45 && angle < 135) {
        result = 2;
    } else if ((angle >= 135 && angle <= 180) || (angle >= -180 && angle < -135)) {
        result = 3;
    } else if (angle >= -45 && angle <= 45) {
        result = 4;
    }

    return result;
}
//阻止页面上下滚
// document.addEventListener("touchstart",function(e){
// 	e.preventDefault();
// 	e.stopPropagation();
// },false)

//手指接触屏幕
document.getElementsByClassName("text_Info")[0].addEventListener("touchstart", function (e) {
    startx = e.touches[0].pageX;
    starty = e.touches[0].pageY;
}, false);
//手指离开屏幕
document.getElementsByClassName("text_Info")[0].addEventListener("touchend", function (e) {
    var endx, endy;
    endx = e.changedTouches[0].pageX;
    endy = e.changedTouches[0].pageY;
    var direction = getDirection(startx, starty, endx, endy);
    switch (direction) {
        case 3:
            $(".next_page").trigger("click")
            break;
        case 4:
            $(".prev_page").trigger("click")
            break;
        default:
    }
}, false);

// 上下滑动加载页面（第二版）
$("#wrapper").unbind("scroll").bind("scroll", function () {
    if (this.scrollHeight == $(this).scrollTop() + $(this).height()) {
        setTimeout(function () {
            pullUpAction('down', 'no');
        }, 1)
        numpage = 1;
    }
})
//手指接触屏幕
document.getElementsByClassName("scroller")[0].addEventListener("touchstart", function (e) {
    startx = e.touches[0].pageX;
    starty = e.touches[0].pageY;
}, false);
//手指离开屏幕
document.getElementsByClassName("scroller")[0].addEventListener("touchend", function (e) {
    var endx, endy;
    endx = e.changedTouches[0].pageX;
    endy = e.changedTouches[0].pageY;
    var direction = getDirection(startx, starty, endx, endy);
    switch (direction) {
        case 2:
            if (document.getElementById("wrapper").scrollTop <= 0) {
                $(".scroller>div").slideDown();
                $("#wrapper").scrollTop(0)
                setTimeout(function () {
                    $(".scroller>div").css("display", "none");
                    pullUpAction('up', 'no');
//                $(".scroller>ul").prepend("<section><p>123</p ><p>123</p ><p>456</p ><p>567</p ><p>678</p ></section>")
//                $("#wrapper").scrollTop($(".scroller>ul>section").eq(0).height() - 50)
                }, 1000)
            }
            ;
//        $("#wrapper").scrollTop($(".scroller>ul>section").eq(0).height() - 50)
            break;
        default:
    }
}, false);

$(".schedule_show span").eq(0).click(function () {
    var cid = $(this).attr('data-up');
    if (cid == 0) {
        $(".message_info_alert>span").html("已是第一章");
        $(".message_info_alert").fadeIn(function () {
            setTimeout(function () {
                $(".message_info_alert").fadeOut()
            }, 300)
        })
    } else {
        location.href = "/novel/novel/chapterContent?novelid=" + novelid + "&chapterid=" + cid;
    }
});

$(".schedule_show span").eq(1).click(function () {
    var cid = $(this).attr('data-down');
    if (cid == 0) {
        $(".message_info_alert>span").html("已是最后一章");
        $(".message_info_alert").fadeIn(function () {
            setTimeout(function () {
                $(".message_info_alert").fadeOut()
            }, 300)
        })
    } else {
        location.href = "/novel/novel/chapterContent?novelid=" + novelid + "&chapterid=" + cid;
    }
});

function pullUpAction(type, sign) {
    if (type == 'down') {
        var chapterid = $('.more span').attr('down');
        if (chapterid == 0) {
            $(".message_info_alert>span").html("没有更多了...");
            $(".message_info_alert").fadeIn(function () {
                setTimeout(function () {
                    $(".message_info_alert").fadeOut()
                }, 300)
            })
            return false;
        }
    } else if (type == 'up') {
        var chapterid = $('.schedule_show>span').eq(0).attr('data-up');
        if (chapterid == 0) {
            $(".message_info_alert>span").html("已是第一章");
            $(".message_info_alert").fadeIn(function () {
                setTimeout(function () {
                    $(".message_info_alert").fadeOut()
                }, 300)
            })
            return false;
        }
    }

    $.ajax({
        url: '/novel/novel/ajaxChapterContent',
        type: 'get',
        dataType: 'json',
        async: false,
        data: {novelid: novelid, chapterid: chapterid},
        success: function (data) {
            if (data.status == 0) {
                var progress = data.data.progress;
                var content = data.data.content;
                $(".aside_booklist>ul>a>li").removeClass("red_title");
                $("#"+progress.order).addClass("red_title");
                $(".red_title").parents("ul").scrollTop($(".red_title").parent().offset().top-$(".red_title").parents("ul").offset().top-200)
                var str = '';
                if (data.data.need_pay > 0) {
                    var balance = '';
                    var need_pay = data.data.need_pay;
                    if (data.data.user['user_balance']) {
                        balance = data.data.user['user_balance'];
                    }
                    str = '<div class="loginMoney">' +
                            '<a href="javascript:;">需消费：' +
                            '<i>' +
                            need_pay +
                            '</i>阅币&nbsp&nbsp&nbsp&nbsp当前剩余：' +
                            '<i>' +
                            balance +
                            '</i>阅币' +
                            '</a>' +
                            '<span>' +
                            '<img check="true" src="/public/img/images/btn-check.png">' +
                            '<a href="javascript:;">自动订阅下一章，不再提醒</a>' +
                            '</span>' +
                            '<div onclick="buyChapter(' + data.data.chapter_id + ')">订阅本章</div>' +
                            '<a class="getmoreSection" href="javascript:;">选择更多章节</a>' +
                            '</div>';
                }
                $(".text_Info_cont").empty();
                $(".text_Info_cont").append("<section>" + content + str + "</section>");
                $(".scroller ul").empty();
                $(".scroller ul").append("<section>" + content + str + "</section>");
                if (sign == 'left') {
                    if (type == 'up') {
                        numpage = a.scrollWidth / document.body.clientWidth;
                        $(".text_Info_cont").css("transform", "translateX(-" + (numpage - 1) * 100 + "%)")
                    }
                }
//                $('.schedule_show>span').eq(0).attr('data-up',progress.up);
                $(".more span").attr('down', progress.down);
                $(".schedule_show span").eq(1).attr('data-down', progress.down);
                var fontSize = parseInt($(".font_set>input").val());
                $(".text_Info p").css("fontSize", fontSize / 46.875 + "rem");
                $("#wrapper p").css("fontSize", fontSize / 46.875 + "rem");
//                $('.scroller ul').html($('.scroller ul').html()+content);
                $(".schedule_show span").eq(0).attr('data-up', progress.up);
                $(".text_Info_cont").css("transform", "translateX(-" + (numpage + 1) * 100 + "%)");
                $(".text_Info_cont").css("transition", "none");
                $(".text_Info_cont").css("transform", "translateX(0)");
                numpage = 1;
                setTimeout(function () {
                    $(".text_Info_cont").css("transition", "transform .2s");
                }, 400)
                $('.more span').text('上拉加载...');
            } else {
                $(".message_info_alert>span").html(data.msg);
                $(".message_info_alert").fadeIn(function () {
                    setTimeout(function () {
                        $(".message_info_alert").fadeOut()
                    }, 300)
                })
            }
        },
        error: function () {
            $(".message_info_alert>span").html("系统错误请稍后再试");
            $(".message_info_alert").fadeIn(function () {
                setTimeout(function () {
                    $(".message_info_alert").fadeOut()
                    window.location.reload();
                }, 300)
            })
        }
    });
}

$(".told_press li").eq(1).on("click", function () {
    $(".told_press").css("display", "none")
    var nid = $(this).attr('data-n');
    var cid = $(this).attr('data-c');
    $.ajax({
        url: '/novel/novel/ajaxChapterContent',
        type: 'get',
        dataType: 'json',
        async: false,
        data: {novelid: nid, chapterid: cid},
        success: function (data) {
            if (data.status == 0) {
                var progress = data.data.progress;
                var content = data.data.content;
                var str = '';
                if (data.data.need_pay > 0) {
                    var balance = '';
                    var need_pay = data.data.need_pay;
                    if (data.data.user['user_balance']) {
                        balance = data.data.user['user_balance'];
                    }
                    str = '<div class="loginMoney">' +
                            '<a href="javascript:;">需消费：' +
                            '<i>' +
                            need_pay +
                            '</i>阅币&nbsp&nbsp&nbsp&nbsp当前剩余：' +
                            '<i>' +
                            balance +
                            '</i>阅币' +
                            '</a>' +
                            '<span>' +
                            '<img check="true" src="/public/img/images/btn-check.png">' +
                            '<a href="javascript:;">自动订阅下一章，不再提醒</a>' +
                            '</span>' +
                            '<div onclick="buyChapter(' + data.data.chapter_id + ')">订阅本章</div>' +
                            '<a class="getmoreSection" href="javascript:;">选择更多章节</a>' +
                            '</div>';
                }
                $(".text_Info_cont").empty();
                $(".text_Info_cont").append("<section>" + content + str + "</section>");
                $(".scroller ul").empty();
                $(".scroller ul").append("<section>" + content + str + "</section>");
//                if (sign == 'left') {
//                    if (type == 'up') {
//                        numpage = a.scrollWidth / document.body.clientWidth;
//                        $(".text_Info_cont").css("transform", "translateX(-" + (numpage - 1) * 100 + "%)")
//                    }
//                }
//                $('.schedule_show>span').eq(0).attr('data-up',progress.up);
                $(".more span").attr('down', progress.down);
                $(".schedule_show span").eq(1).attr('data-down', progress.down);
                var fontSize = parseInt($(".font_set>input").val());
                $(".text_Info p").css("fontSize", fontSize / 46.875 + "rem");
                $("#wrapper p").css("fontSize", fontSize / 46.875 + "rem");
//                $('.scroller ul').html($('.scroller ul').html()+content);
                $(".schedule_show span").eq(0).attr('data-up', progress.up);
                $('.more span').text('上拉加载...');
            } else {
                $(".message_info_alert>span").html(data.msg);
                $(".message_info_alert").fadeIn(function () {
                    setTimeout(function () {
                        $(".message_info_alert").fadeOut()
                    }, 300)
                })
            }
        },
        error: function () {
            $(".message_info_alert>span").html("系统错误请稍后再试");
            $(".message_info_alert").fadeIn(function () {
                setTimeout(function () {
                    $(".message_info_alert").fadeOut()
                    window.location.reload();
                }, 300)
            })
        }
    });
})

if ($('.scroller').height() < $('#wrapper').height()) {
    $('.more').hide();
//	myscroll.destroy();
}

function sessionStyle() {
    sessionStorage.fontSize = $(".font_set>input").val();
    if ($(".read_time").attr("check") == "true") {
        sessionStorage.readBack = "night";
    } else {
        sessionStorage.readBack = $(".set>ul>li.active").index()
    }
    sessionStorage.readStyle = $(".set>p.active").index();
}


// 返回上一个页面
$(".return_back").on("click", function () {
    sessionStyle();
    userSet(sessionStorage);
    window.history.back();
})
//回到首页
$(".return_home").on("click", function () {
    sessionStyle();
    userSet(sessionStorage);
    location.href = "../novel/novelHomePage";
})
//跳转到我的书架
$(".bookcase").on("click", function () {
    sessionStyle();
    userSet(sessionStorage);
    location.href = "../user/myBookcase?type=1";
})

function userSet(obj) {
    $.ajax({
        url: "/novel/user/userSet",
        type: "post",
        dataType: "json",
        data: {back: obj.readBack, size: obj.fontSize, style: obj.readStyle},
        success: function (data) {
            console.log(data);
        }
    });
}

//进度标题字数限制15个
if ($(".schedule_show>p>a").eq(0).html().length > 15) {
    $(".schedule_show>p>a").eq(0).html($(".schedule_show>p>a").eq(0).html().slice(0, 15) + "...")
}

//默认情况下阻止上下滑动
document.getElementsByClassName("box_box")[0].addEventListener("touchmove", function (e) {
    var e = e || event;
    e.preventDefault()
});

$(".loginMoney>div").on("click", function (e) {
    var e = e || event;
    e.stopPropagation();
//    alert(1);
})

function buyChapter(chapterid, e) {
    var e = e || event;
    e.stopPropagation();
//    alert(chapterid);
}



